package chapter01.principle.crp.improve;

//正确示例：通过组合实现行为
interface Flyable {
    void fly();
}

class Bird {
    private Flyable flyBehavior;
    public Bird(Flyable flyBehavior) {
        this.flyBehavior = flyBehavior;
    }
    public void performFly() {
        flyBehavior.fly();
    }
}

class Penguin extends Bird {
    public Penguin() {
        super(new NoFly()); // 组合无飞行行为
    }
}

class NoFly implements Flyable {
    public void fly() { /* 无动作 */ }
}
